package Test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;

public class A2 {
    public static void main(String[] args) throws IOException {
        // 要能呗客户端所连接，端口号要一致
        ServerSocket server = new ServerSocket(8888);
        // 建立连接
        Socket socket = server.accept();
        // 建立好连接后，就可以接受数据了
        InputStream is = socket.getInputStream();
        BufferedReader rd = new BufferedReader(new InputStreamReader(is));	// 字符缓冲流读文字消息更方便
        String s;
        while ((s = rd.readLine()) != null) {
            System.out.println(new Date()+ "\n" + s);
        }
    }


}
